#############################################
# RTMP Constants
#############################################

RTMP_PORT = 1935
RTMP_VERSION = '\x03'

# RTMP connection states
RTMP_UNINITIALIZED = 0
RTMP_VERSION_SENT = 1
RTMP_ACK_SENT = 2
RTMP_DONE = 3
RTMP_ERROR = 4

# Chunk Stream IDs
CSID_CONTROL_STREAM = 2    # used for chunk stream level messages
CSID_COMMAND_STREAM = 3    # used for RTMP command messages

CSIDS = {2 : "CONTROL_STREAM",
         3 : "COMMAND_STREAM"}

# Message Type IDs
MTYPE_SET_CHUNK_SIZE = 1   # tell peer to use new chunk size
MTYPE_ABORT = 2            # notify peer that stream is closed
MTYPE_WINDOW_ACK = 3       # ack a window's worth of bytes received
MTYPE_USER_CONTROL = 4     # for controlling streams (see UCTRL types below)
MTYPE_WINDOW_SIZE_ACK = 5  # ack the window size request
MTYPE_SET_PEER_BW = 6      # set peer bandwidth
MTYPE_AMF3_COMMAND = 17    # connect, play, pause, result, RPC, etc.
MTYPE_AMF3_DATA = 15       # send metadata (e.g. creation time, duration)
MTYPE_AMF3_SHARED_OBJ = 16 # query/update shared objects
MTYPE_AMF0_COMMAND = 20    # (same as AMF3)
MTYPE_AMF0_DATA = 18       # (same as AMF3)
MTYPE_AMF0_SHARED_OBJ = 19 # (same as AMF3)
MTYPE_AUDIO = 8            # audio data
MTYPE_VIDEO = 9            # video data
MTYPE_AGGREGATE = 22       # list of messages

MTYPES = {1 : "SET_CHUNK_SIZE",
          2 : "ABORT",
          3 : "WINDOW_ACK",
          4 : "USER_CONTROL",
          5 : "WINDOW_SIZE_ACK",
          6 : "SET_PEER_BW",
          8 : "AUDIO",
          9 : "VIDEO",
          15: "AMF3_DATA",
          16: "AMF3_SHARED_OBJ",
          17: "AMF3_COMMAND",
          18: "AMF0_DATA",
          19: "AMF0_SHARED_OBJ",
          20: "AMF0_COMMAND",
          22: "AGGREGATE_MSG"}

# User Control Message Event Types
UCTRL_STREAM_BEGIN = 0     # stream X is now functional
UCTRL_STREAM_EOF = 1       # stream X is complete (no more data)
UCTRL_STREAM_DRY = 2       # stream X is temporarily out of data
UCTRL_SET_BUFFER_LEN = 3   # client informs server of buffer size
UCTRL_IS_RECORDED = 4      # notify client that stream is recorded (not live)
UCTRL_PING_REQUEST = 6     # check if client is reachable
UCTRL_PING_RESPONSE = 7    # client says "I'm here!"

UCTRLS = {0 : "STREAM_BEGIN",
          1 : "STREAM_EOF",
          2 : "STREAM_DRY",
          3 : "SET_BUFFER_LEN",
          4 : "IS_RECORDED",
          5 : "PING_REQUEST",
          6 : "PING_RESPONSE"}

# Message Stream IDs
SID_CONTROL_STREAM = 0     # used for protocol control messages

SIDS = {0 : "CONTROL_STREAM"}

# NetConnection Commands
NCCOM_CONNECT = "connect"
NCCOM_CALL = "call"
NCCOM_CLOSE = "close"
NCCOM_CREATE_STREAM = "createStream"
